<?php

class InvoiceexportController extends Controller{
    public function filters() {
        return array(
            'accessControl', // perform access control for CRUD operations
            array(
                'application.filters.RequireLoginFilter',
            ),
        );
    }

    /**
     * Specifies the access control rules.
     * This method is used by the 'accessControl' filter.
     * @return array access control rules
     */
    public function accessRules() {
        return array(
            array('allow', // allow all users to perform 'index' and 'view' actions
                'users' => array('@'),
            ),
            array('deny', // deny all users
                'users' => array('*'),
            ),
        );
    }
    
    public function actionIndex(){
        
        $model=new InvoiceReportForm();
        $showTemplate=false;
        if(isset($_POST['InvoiceReportForm'])){
            $model->setAttributes($_POST['InvoiceReportForm']);
            if($model->validate()){
                $showTemplate=true;
                
                $this->render('template',array(
                    'model'=>$model,
                    'invoiceList'=>$model->getData()
                ));
            }
        }
        if( ! $showTemplate){
            $this->render('index',array(
                    'model'=>$model
                ));
        }
        
    }
    
}
?>
